# -*- coding: utf-8 -*-
from src.com.ydzy.app.stragety_init import env
from src.com.ydzy.util.base_util import BaserUtil
from src.com.ydzy.util.http_util import HttpClient

http_client = HttpClient()
base_client=BaserUtil()

active=env.active
env_dict={
    'test':'https://audit.gat.gz/',
    'local':'http://localhost:20028/',
}
interface='auditcenter/log_strategies/'
base_strategy_id=171
strategy_list=[i for i in range(172,187)]

def get_req_url(active):
    req_url=env_dict[active]+interface
    return req_url

def get_stragety_data(res):
    copy={}
    copy.update(res)
    copy=copy['data']
    if 'logType_text' in copy:
        del copy['logType_text']
    if 'updateTime' in copy:
        del copy['updateTime']
    return copy

url=get_req_url(active)+str(base_strategy_id)+'?embed=fieldInfos,pageOpt,perms'
res = http_client.get(url, fast_falg=True)
tmp=base_client.json2obj(res)['data']['fieldInfos']
field_infos=[]
for item in tmp:
    item['relType']='02'
    field_infos.append(item)


def main():
    for i in strategy_list:
        url = get_req_url(active)+str(i)
        res=http_client.get(url,fast_falg=True)
        data=get_stragety_data(base_client.json2obj(res))
        data['fieldInfos']=field_infos
        print(f'请求报文--->{base_client.obj2json(data)}')
        res2=http_client.put(url=url,data=data,fast_falg=True)



if __name__=='__main__':
    main()